public class Square extends Rectangle
{
    public Square()
    {
        this(new Point(),new Point());
    }

    public Square(Point p1,Point p2)
    {
        super(new Point(Math.min(p1.getX(),p2.getX()),Math.min(p1.getY(),p2.getY())),Math.max(p1.getX(),p2.getX())-Math.min(p1.getX(),p2.getX()),Math.max(p1.getX(),p2.getX())-Math.min(p1.getX(),p2.getX()));
        this.shape="正方形";
    }

    public Square(Point p1,double length)
    {
        this(p1,new Point(p1.getX()+length,p1.getY()+length));
    }

    public Square(Square r)
    {
        this(r.point1,r.length);
    }

//    public String toString()
//    {
//        return "Square{"+
//                "shape='"+shape+'\''+
//                ", point1="+point1+
//                ", length="+length+
//                ", width="+width+
//                '}';
//    }

    public String toString()
    {
        return "new Square("+point1+","+length+")";
    }
}
